﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace chess
{
    public class csField
    {

        private enumFieldStatus _status = enumFieldStatus.Empty;
        private csFig _fig = null;
        private int _spalte = 0;
        private int _zeile = 0;
        private bool _marked = false;
        private bool _offended = false;

        public csField(enumFieldStatus status, int spalte, int zeile)
        {
            this._status = status;
            this._spalte = spalte;
            this._zeile = zeile;
        }

        public int Spalte
        {
            get { return this._spalte;  }
        }

        public int Zeile
        {
            get { return this._zeile; }
        }

        public enumFieldStatus Status
        {
            get { return this._status; }
        }

        public int Value
        {
            get
            {
                int result = 0;
                switch (_status)
                {
                    case enumFieldStatus.Empty:
                        result = 0;
                        break;
                    case enumFieldStatus.Black:
                        result = this._fig.Value;
                        break;
                    case enumFieldStatus.White:
                        result = this._fig.Value;
                        break;
                    default:
                        result = -1;
                        break;
                }
                return result;
            }
        }

        public void SetFig(csFig fig)
        {
            this._fig = fig;

            switch (fig.Party)
            {
                case enumFigParty.Black:
                    this._status = enumFieldStatus.Black;
                    break;
                case enumFigParty.White:
                    this._status = enumFieldStatus.White;
                    break;
                default:
                    break;
            }
        }

        public csFig GetFig
        {
            get { return this._fig; }
        }

        public void ClearField()
        {
            this._status = enumFieldStatus.Empty;
            this._fig = null;
        }

        public bool Marked
        {
            get { return this._marked; }
            set { this._marked = value; }
        }

        public bool Offended
        {
            get { return this._offended; }
            set { this._offended = value; }
        }

    }
}
